
import Taro, {Component} from '@tarojs/taro'
import {View, Image} from '@tarojs/components'
import {inject, observer} from '@tarojs/mobx'
import {companyName, pageSize, navigateTo, articleType} from "../../utils/common";

import {IStoreProps} from '../../store/Stores'

import './aboutus.scss'
import './help.scss'
import icon_17 from '../../assets/img/qlj.jpg'

interface IHomeProps extends IStoreProps {
}

@inject("stores")
@observer
class Aboutus extends Component<IHomeProps> {
  constructor(props) {
    super(props)
  }

  state = {
    pageIndex: 1,
    pageSize: pageSize,
    totalCount: 0,
    items: [] as any[]
  }

  componentWillMount(): void {
    this.getItems()
  }

  link = (url: string = '/pages/index/index'): void => {
    navigateTo(url)
  }

  getItems(): void {
    let { dynamicStore } = this.props.stores
    let { pageIndex, pageSize } = this.state
    dynamicStore.getArticleList({
      id: articleType.help,
      pageIndex,
      pageSize,
      callback: res => {
        if (pageIndex === 1) {
          this.setState({totalCount: res.totalCount, items:res.items})
        }else {
          const { items } = this.state;
          items.push(...res.items || []);
          this.setState({totalCount: res.totalCount, items})
        }
      }
    })
  }

  onReachBottom(): void {
    let {totalCount, pageSize, pageIndex} = this.state
    const {loading} = this.props.stores.homeStore;
    if (totalCount > pageIndex * pageSize && !loading) {
      this.setState({
        pageIndex: pageIndex + 1
      }, () => {
        this.getItems()
      })
    }
  }

  render() {
    let { items } = this.state
    return (
      <View className='page-bg content-20'>

        <Image className='about-icon' src={icon_17} style={{width: '100%',height:'auth',borderRadius:'10px',margin:0}} />

        {/* <Image className='about-icon' src={icon_17} />
        <View className='list-help'>
          {
            items.map(item => {
              return(
                <View className='list-help__item' onClick={this.link.bind(this, '/pages/mine/helpDetail?id='+item.id)} key={item.id}>
                  <View className='list-help__title icon-link-theme'>{item.artTitle}</View>
                </View>
              )
            })
          }
          <View className='list-help__item' onClick={this.link.bind(this, '/pages/share/qrCode')} >
            <View className='list-help__title icon-link-theme' style={{justifyContent: 'flexStart'}}>微信公众号</View>
          </View>
        </View>

        <View className='footer-info'>
          <View>{companyName}  版权所有</View>
          <View>Copyright © 2019 - 2020 YYTX. All Right Reserved.</View>
        </View> */}

      </View>
    )
  }
}

export default Aboutus

